$(function () {
    //咨询量和电话成本
    var inquiries = echarts.init(document.getElementById('inquiries'));
    var inquiries_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {
                    show: true,
                    readOnly: false,
                },
                magicType: {
                    show: true,
                    type: ['line', 'bar']
                },
                restore: {
                    show: true
                },
                saveAsImage: {
                    show: true
                }
            },
            right: 20
        },
        legend: {
            data: ['咨询量', '成本'],
            icon: 'circle',
            left: '7%'
        },
        color: ['#91c7ae', '#2f4554'],
        xAxis: [
            {
                type: 'category',
                data: ['2016年1月', '2016年2月', '2016年3月', '2016年4月', '2016年5月', '2016年6月', '2016年7月', '2016年8月', '2016年9月', '2016年10月', '2016年11月', '2016年12月', '2017年1月'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 14000,
                interval: 2000,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 50,
                max: 400,
                interval: 50,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '咨询量',
                type: 'bar',
                data: [6511, 6788, 12600, 5012, 6055, 5400, 6602, 8020, 7823, 10345, 9209, 7899, 3204],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '成本',
                type: 'line',
                yAxisIndex: 1,
                data: [150.9, 120.8, 104.6, 108.5, 116.3, 118.2, 107.3, 98.4, 95.0, 76.5, 99.0, 83.8, 99.2],
                label: {
                    normal: {
                        show: true,
                    }
                }
            }
        ]
    };
    inquiries.setOption(inquiries_option);


    //上门量、报名量
    var application = echarts.init(document.getElementById('application'));
    var application_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['上门量', '报名量', '电转', '面转'],
            icon: 'circle',
            left: '7%',
            itemGap: 50
        },
        color: ['#91c7ae', '#2f4554', 'blue', 'rgb(255,23,140)'],
        xAxis: [
            {
                type: 'category',
                data: ['青岛', '大连', '长春', '金华', '天津', '深圳', '福州', '济南', '广州', '杭州', '太原', '徐州', '厦门', '哈尔滨', '北京', '成都', '长沙', '上海', '苏州', '武汉'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 200,
                interval: 50,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '上门量',
                type: 'bar',
                data: [10, 18, 100, 23, 88, 9, 180, 45, 89, 120, 38, 88, 128, 68, 180, 45, 89, 120, 38, 88],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '报名量',
                type: 'bar',
                yAxisIndex: 1,
                data: [5, 10, 55, 13, 56, 2, 80, 23, 65, 65, 24, 67, 57, 23, 34, 42, 26, 80, 33, 50],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [9, 9, 8, 16, 12, 10, 8, 11, 6, 16, 12, 18, 28, 19, 18, 15, 29, 12, 8, 18],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '面转',
                type: 'line',
                yAxisIndex: 1,
                data: [100, 94, 89, 66, 63, 78, 85, 76, 70, 63, 68, 79, 88, 90, 80, 85, 89, 90, 98, 92],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    application.setOption(application_option);

    //客单价
    var customerTransaction = echarts.init(document.getElementById('customerTransaction'));
    var customerTransaction_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['客单价', '推广费比', '电转', '面转'],
            icon: 'circle',
            left: '7%'
        },
        color: ['#91c7ae', 'red', '#2f4554', 'rgb(255,23,140)'],
        xAxis: [
            {
                type: 'category',
                data: ['常州', '大连', '天津', '北京', '苏州', '上海', '宁波', '厦门', '福州', '深圳', '合肥', '徐州', '厦门', '西安', '广州', '杭州', '徐州', '金华', '哈尔滨', '南京','成都','太原','沈阳','长春','武汉','济南','石家庄','重庆','郑州','长沙'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 2500,
                interval: 500,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 20,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '客单价',
                type: 'bar',
                data: [2012, 1690, 1849, 1920, 1720, 1603, 1681, 2335, 1236, 2389, 1580, 1087, 1245, 2341, 1578, 1789, 1600, 2300, 1800, 2188,1809,1509,1280,1109,1564,1800,2100,1689,1632,1867],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '推广费比',
                type: 'line',
                yAxisIndex: 1,
                data: [0, 18, 22, 25, 29, 32, 36, 38, 42, 45, 50, 52, 54, 56, 58, 62, 68, 75, 82, 82,78, 45, 40, 36, 45, 48, 52, 54, 46, 58],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [9, 9, 8, 16, 12, 10, 8, 11, 6, 16, 12, 18, 28, 19, 18, 15, 29, 12, 8, 18,12, 10, 8, 11, 6, 16, 12, 18, 28, 19,],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '面转',
                type: 'line',
                yAxisIndex: 1,
                data: [0, 80, 89, 66, 63, 78, 85, 76, 70, 63, 68, 79, 84, 88, 80, 82, 78, 86, 90, 92, 68, 79, 84, 88, 80, 85, 89, 90, 98, 92],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    customerTransaction.setOption(customerTransaction_option);

    //电转、面转
    var phoneChange = echarts.init(document.getElementById('phoneChange'));
    var phoneChange_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            show: true,
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                dataView: {readOnly: false},
                magicType: {type: ['line', 'bar']},
                restore: {},
                saveAsImage: {}
            }
        },
        xAxis:  {
            type: 'category',
            boundaryGap: false,
            data: ['周一','周二','周三','周四','周五','周六','周日']
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value} °C'
            }
        },
        series: [
            {
                name:'最高气温',
                type:'line',
                data:[11, 11, 15, 13, 12, 13, 10]
            }
        ]
    };
    phoneChange.setOption(phoneChange_option);

    //业绩与推广费/电转比例
    var performancPhone = echarts.init(document.getElementById('performancPhone'));
    var performancPhone_option = {
        title: {
            text: '最近八天运营数据',
            left: 'center'
        },
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['广告费', '业绩合计', '推广费比', '电转'],
            icon: 'circle',
            left: '7%',
            itemGap: 50
        },
        color: ['#91c7ae', '#FD817E', '#FF7902', '#000'],
        xAxis: [
            {
                type: 'category',
                data: ['12月31日', '1月1日', '1月2日', '1月3日', '1月4日', '1月5日', '1月6日', '1月7日'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 400000,
                interval: 100000,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '广告费',
                type: 'bar',
                data: [81170, 91976, 126267, 172734, 147963, 126918, 69392,24568],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '业绩合计',
                type: 'bar',
                data: [314514, 73452, 106980, 203862, 233619, 220322, 263791,18825],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '推广费比',
                type: 'line',
                yAxisIndex: 1,
                data: [36, 38, 51, 92, 67, 62, 58, 50],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [27, 6.2, 5.1, 7.0, 7.5, 9.7, 28, 8.2],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    performancPhone.setOption(performancPhone_option);


    //业绩与推广费
    var performancPromotion = echarts.init(document.getElementById('performancPromotion'));
    var performancPromotion_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {
                    show: true,
                    readOnly: false,
                },
                magicType: {
                    show: true,
                    type: ['line', 'bar']
                },
                restore: {
                    show: true
                },
                saveAsImage: {
                    show: true
                }
            },
            right: 20
        },
        legend: {
            data: ['业绩合计', '推广费比'],
            icon: 'circle',
            left: '7%'
        },
        color: ['#00BAFF', '#FF0928'],
        xAxis: [
            {
                type: 'category',
                data: ['常州', '大连', '天津', '北京', '苏州', '上海', '宁波', '厦门', '福州', '深圳', '合肥', '徐州', '厦门', '西安', '广州', '杭州', '徐州', '金华', '哈尔滨', '南京','成都','太原','沈阳','长春','武汉','济南','石家庄','重庆','郑州','长沙'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 4000000,
                interval: 1000000,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '业绩合计',
                type: 'bar',
                data: [223888, 346870, 1296870, 2237368, 1589489, 616870, 1237368,216870, 316870, 716870, 116870, 516870, 316870,216870,816870,1316870,2316870,3616870,2816870,2516870,2216870,1816870,3016870,816870,1616870,216870,516870,616870,1016870,916870],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '推广费比',
                type: 'line',
                yAxisIndex: 1,
                data: [0, 15,18,24,28,35,38,42,45,48,52,56,59,60,62,68,69,72,76,78,82,85,86,89,91,93,95,96,98,93],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    };
    performancPromotion.setOption(performancPromotion_option);

    //月度概况
    var monthly = echarts.init(document.getElementById('monthly'));
    var monthly_option = {
        title: {
            text: '月度概况',
            left: 'center'
        },
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['广告费', '业绩合计','推广费比', '电转', '面转'],
            icon: 'circle',
            left: '7%',
            itemGap: 50
        },
        color: ['#91c7ae', '#FD817E', '#FF7C59', '#000','#FF39D5'],
        xAxis: [
            {
                type: 'category',
                data: ['2016年1月', '2016年2月', '2016年3月', '2016年4月', '2016年5月', '2016年6月', '2016年7月', '2016年8月', '2016年9月', '2016年10月', '2016年11月', '2016年12月', '2017年1月'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 4000000,
                interval: 1000000,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '广告费',
                type: 'bar',
                data: [312888, 312888, 512888, 23, 88, 9, 180, 45, 89, 120, 38, 88, 128, 68, 180, 45, 89, 120, 38, 88],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '业绩合计',
                type: 'bar',
                data: [893476, 823476, 3612888, 13, 56, 2, 80, 23, 65, 65, 24, 67, 57, 23, 34, 42, 26, 80, 33, 50],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '推广费比',
                type: 'line',
                yAxisIndex: 1,
                data: [9, 9, 8, 16, 12, 10, 8, 11, 6, 16, 12, 18, 28, 19, 18, 15, 29, 12, 8, 18],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [9, 9, 8, 16, 12, 10, 8, 11, 6, 16, 12, 18, 28, 19, 18, 15, 29, 12, 8, 18],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '面转',
                type: 'line',
                yAxisIndex: 1,
                data: [70, 69, 68, 66, 61, 63, 65, 67, 69, 61, 65, 69, 66],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    monthly.setOption(monthly_option);

    //咨询师业绩
    var performanc = echarts.init(document.getElementById('performanc'));
    var performanc_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['分校', '集团', '十里河团队','学慧网团队','郑州团队','电转', '面转'],
            icon: 'circle',
            left: '7%',
            itemGap: 50
        },
        color: ['#91c7ae', '#2f4554', 'blue', 'rgb(255,23,140)'],
        xAxis: [
            {
                type: 'category',
                data: ['青岛', '大连', '长春', '金华', '天津', '深圳', '福州', '济南', '广州', '杭州', '太原', '徐州', '厦门', '哈尔滨', '北京', '成都', '长沙', '上海', '苏州', '武汉'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 200,
                interval: 50,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '分校',
                type: 'bar',
                data: [10, 18, 100, 23, 88, 9, 180, 45, 89, 120, 38, 88, 128, 68, 180, 45, 89, 120, 38, 88],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [9, 9, 8, 16, 12, 10, 8, 11, 6, 16, 12, 18, 28, 19, 18, 15, 29, 12, 8, 18],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '面转',
                type: 'line',
                yAxisIndex: 1,
                data: [100, 94, 89, 66, 63, 78, 85, 76, 70, 63, 68, 79, 88, 90, 80, 85, 89, 90, 98, 92],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    performanc.setOption(performanc_option);

    //咨询师总业绩合计
    var overallPerformance = echarts.init(document.getElementById('overallPerformance'));
    var overallPerformance_option = {
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            },
            right: 20
        },
        legend: {
            data: ['业绩合计','电转', '面转'],
            icon: 'circle',
            left: '7%',
            itemGap: 50
        },
        color: ['#FD817E', '#673B5D', '#000'],
        xAxis: [
            {
                type: 'category',
                data: ['2016/12/1', '2016/12/2', '2016/12/3', '2016/12/4', '2016/12/5', '2016/12/6', '2016/12/7', '2016/12/8', '2016/12/9', '2016/12/10', '2016/12/11', '2016/12/12', '2016/12/13', '2016/12/14', '2016/12/15', '2016/12/16', '2016/12/17', '2016/12/18', '2016/12/19', '2016/12/20'],
                axisTick: {
                    show: false
                }
            }
        ],
        yAxis: [
            {
                name: '',
                type: 'value',
                min: 0,
                max: 400000,
                interval: 100000,
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            {
                name: '',
                type: 'value',
                min: 0,
                max: 100,
                interval: 25,
                axisLabel: {
                    formatter: '{value} %'
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '业绩合计',
                type: 'bar',
                data: [225297, 165297, 175247, 185597, 228643, 128643, 50643, 285597, 315597, 355597, 235597, 195597, 175597, 185597, 255597, 225597, 295597, 315597, 325597, 285597],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '电转',
                type: 'line',
                yAxisIndex: 1,
                data: [69, 64, 67, 71, 79, 70, 67, 69, 68, 66, 60, 58, 59, 62, 63, 65, 68, 58, 72, 68],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            },
            {
                name: '面转',
                type: 'line',
                yAxisIndex: 1,
                data: [15, 14, 13, 16, 18, 12, 6, 26, 20, 30, 28, 27, 26, 25, 28, 27, 26, 28, 29, 30],
                label: {
                    normal: {
                        show: true,
                        position: 'top',
                        formatter: '{c} %',
                        textStyle: {
                            color: '#000'
                        }
                    }
                }
            }
        ]
    }
    overallPerformance.setOption(overallPerformance_option);

    //图表插件屏幕自适应
    $(window).on('resize', function () {
        inquiries.resize();
        application.resize();
        customerTransaction.resize();
        phoneChange.resize();
        performancPhone.resize();
        overallPerformance.resize();
    })
})
